"""MyDjango URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.urls import path, include
from django.urls import re_path
from django.views.decorators.cache import cache_page
# from index.views import ProductClassAPIView, ProductClass
from . import views
# from index.views import MySearchView

urlpatterns =[
    # 基于方法或者是函数实现的视图，称为FBV
    # path('', views.index),
    # 带有字符类型、整型和slug的url
    # path('<year>/<int:month>/<slug:day>', views.mydate),   # path('<str:year>/<int:month>/<slug:day>', views.mydate),
    # path('<text>', views.gettext),
    # re_path('(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2}).html', views.mynewdate)
    # re_path('(?P<year>[0-9]{4}).html', views.myyear, name='myyear'),
    # path('download.html', views.download),
    # path('hello', views.hello),
    # path('login', views.login),
    # 采用通用视图ListView来实现，实际上这就是CBV，也就是基于类实现的视图
    # path('index/', views.ProductList.as_view()),
    # path('index/<id>', views.ProductList.as_view(), {'name': 'phone'}),
    # path('test', views.test),

    # 数据库表单，基于函数FBV
    # path('<int:id>.html', views.model_index),
    # 数据库表单，基于类CBV
    # path('<int:id>', views.ModelIndexView.as_view()),



    # 首页的url,演示session机制时使用
    # path('', views.index, name='index'),
    #
    # # 购物车
    # path('shoppingcart', views.ShoppingCart, name='shoppingcart'),



    # 首页的url,演示路由缓存
    # path('', cache_page(timeout=10, cache='MyDjango', key_prefix='MyDjangoURL')(views.index), name='index'),
    # # 购物车
    # path('shoppingcart', views.ShoppingCart, name='shoppingcart'),




    # 首页的url,演示消息提示
    # path('', views.index, name='index'),
    # # 购物车
    # path('shoppingcart', views.ShoppingCart, name='shoppingcart'),
    # # 消息提示
    # path('message', views.message, name='message'),




    # # 首页的url,演示分页功能
    # path('', views.index, name='index'),
    # # 购物车
    # path('shoppingcart',views.ShoppingCart, name='shoppingcart'),
    # # 分页功能
    # path('pagination/<int:page>', views.PaginationTest, name='pagination'),




    # 演示django rest framework框架的序列化功能
    # 基于类的视图CBV
    # 访问url为http://127.0.0.1/?page=1
    # path('', ProductClassAPIView.as_view()),
    #
    # # 基于函数的视图FBV
    # # 访问url为http://127.0.0.1/3
    # path('<int:pk>', views.ProductClass),



    # 演示基于haystack的站内搜索功能
    # 基于类的视图CBV
    # path('search', views.SearchView(), name='haystack'),



    # 首页的url,演示分布式任务系统
    path('', views.IndexCelery)
]